package project4;

import java.util.ArrayList;
import java.util.HashMap;

public class TupleHashMap extends HashMap<String,String>  implements Comparable<TupleHashMap> {

	private ArrayList<String> schema;
	public TupleHashMap(ArrayList<String> schema){
		this.schema = schema;
	}
	public int compareTo(TupleHashMap that) {
		final int BEFORE = -1;
		final int EQUAL = 0;
		final int AFTER = 1;
		
		
		int result;
		if (that == null ) {
			result = -1;
		}
		//Loop through every variable
		//If the value of this comes before the value of that, then return BEFORE
		//If the value of this comes after the value of that, then return AFTER
		//If they are equal do nothing and continue
		for (String variable : schema){
			if(this.get(variable).compareTo(that.get(variable)) > 0 )
				return AFTER;
			else if(this.get(variable).compareTo(that.get(variable)) < 0 )
				return BEFORE;
		}
		return 0;
	}

}
